<template>
  <!-- <fullscreen :fullscreen.sync="fullscreen"> -->
  <div>
    <div
      class="container"
      style="width: 100%; height: 100%"
      v-show="fullscreen"
    >
      <el-container
        style="
          height: 100%;
          width: 100%;
          display: flex;
          justify-content: space-between;
        "
      >
        <!-- <el-aside -->
        <div class="sidePosi">
          <div>
            <el-button class="studentforn" @click="shwostudent = !shwostudent"
              >考生信息</el-button
            >
            <el-card class="box-card" v-show="shwostudent">
              <div class="img">
                <img
                  style="border: 2px solid #e4e7ed; width: 150px; height: 150px"
                  src="./daifu.png"
                />
              </div>
              <div>
                姓名：
                <span
                  style="color: #909399"
                  v-if="studentMsg.nickName !== null"
                  >{{ studentMsg.nickName }}</span
                >
                <span style="color: #909399" v-else>暂无</span>
              </div>
              <div>
                学号：
                <span
                  style="color: #909399"
                  v-if="studentMsg.studentNumber !== null"
                >
                  {{ studentMsg.studentNumber }}</span
                >
                <span style="color: #909399" v-else>暂无</span>
              </div>
              <div>
                班级名称：
                <span
                  style="color: #909399"
                  v-if="studentMsg.className !== null"
                >
                  {{ studentMsg.className }}</span
                >
                <span style="color: #909399" v-else>暂无</span>
              </div>
              <div>
                专业名称：
                <span
                  style="color: #909399"
                  v-if="studentMsg.majorName !== null"
                  >{{ studentMsg.majorName }}</span
                >
                <span style="color: #909399" v-else>暂无</span>
              </div>
              <div>
                学院名称：
                <span
                  style="color: #909399"
                  v-if="studentMsg.collegeName !== null"
                  >{{ studentMsg.collegeName }}</span
                >
                <span style="color: #909399" v-else>暂无</span>
              </div>
            </el-card>
            <!-- <div class="timeclick">
                <span class="spantime"
                  ><i class="el-icon-bell"></i>{{ time }}</span
                >
              </div> -->
          </div>
          <el-menu
            style="margin-bottom: 50px"
            default-active="2"
            :unique-opened="true"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
            @select="chosemue"
          >
            <el-submenu
              :index="item.index + ''"
              v-for="(item, i) in paper.structureList"
              :key="i"
            >
              <template slot="title">
                <span
                  style="
                    display: block;
                    width: 90%;
                    overflow: hidden;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                  "
                >
                  {{ item.name }}</span
                >
              </template>
              <!-- 循环生成菜单 -->
              <el-menu-item
                :index="item.index + '-' + item1.index"
                v-for="(item1, i1) in item.bankList"
                :key="i1"
              >
                <span
                  style="
                    display: block;
                    width: 90%;
                    overflow: hidden;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                  "
                >
                  {{ item.type }}--第{{ i1 + 1 }}题</span
                ></el-menu-item
              >
            </el-submenu>
          </el-menu>
          <div style="position: fixed; bottom: 35px; width: 15%">
            <el-button type="success" @click="exitanswer()" class="subbutton">
              退出
            </el-button>
          </div>
        </div>
        <!-- </el-aside> -->

        <div
          style="
            width: 84%;
            border: 1px solid rgb(238, 238, 238);
            margin-left: 18%;
          "
        >
          <el-container style="" width="70%">
            <el-header class="el-header">
              <el-breadcrumb
                separator-class="el-icon-arrow-right"
                class="header"
              >
                <el-breadcrumb-item
                  >part{{ breadcrumb.first }}--{{
                    breadcrumb.type
                  }}</el-breadcrumb-item
                >
                <el-breadcrumb-item
                  >第{{ breadcrumb.second }}题</el-breadcrumb-item
                >
              </el-breadcrumb>
            </el-header>
            <!-- <el-main>题目</el-main>
            <ShowPaper
              :paper="paper"
              :row="templatepape"
              v-if="shwopaper"
            ></ShowPaper>-->

            <el-main width="100%">
              <!-- 题目 -->
              <ShowPaper
                :paper="paper"
                :row="templatepape"
                v-if="shwopaper"
              ></ShowPaper>
            </el-main>
          </el-container>
        </div>
      </el-container>
    </div>
    <el-dialog
      :visible.sync="answercardDialogVisible"
      :modal="true"
      width="70%"
      center
    >
      <div>
        <div class="ansekahead">
          <!-- 贵州中医大学2019-2020年第一学期《公共关系补考》 -->
          {{ paper.name }}
        </div>
        <el-container class="studentmsg">
          <div class="studentmsg-ietm">
            <span
              >考生姓名：{{ studentMsg.nickName }}
              <span v-if="studentMsg.nickName == null">暂无</span></span
            >
            <span
              >学号：{{ studentMsg.studentNumber }}
              <span v-if="studentMsg.studentNumber == null">暂无</span></span
            >
            <span
              >学院名称：{{ studentMsg.collegeName
              }}<span v-if="studentMsg.collegeName == null">暂无</span></span
            >
            <span
              >专业名称：{{ studentMsg.majorName }}
              <span v-if="studentMsg.majorName == null">暂无</span></span
            >
            <span>
              班级名称：{{ studentMsg.className }}
              <span v-if="studentMsg.className == null">暂无</span></span
            >
          </div>
        </el-container>
      </div>
      <div>
        <div class="ansekahead">
          <!-- 贵州中医大学2019-2020年第一学期《公共关系补考》 -->
          {{ paper.name }}
        </div>
        <div class="studentmsg">
          <div class="studentmsg-ietm">
            <span
              >考生姓名：{{ studentMsg.nickName }}
              <span v-if="studentMsg.nickName == null">暂无</span></span
            >
            <span
              >学号：{{ studentMsg.studentNumber }}
              <span v-if="studentMsg.studentNumber == null">暂无</span></span
            >
            <span
              >学院名称：{{ studentMsg.collegeName
              }}<span v-if="studentMsg.collegeName == null">暂无</span></span
            >
            <span
              >专业名称：{{ studentMsg.majorName }}
              <span v-if="studentMsg.majorName == null">暂无</span></span
            >
            <span>
              班级名称：{{ studentMsg.className }}
              <span v-if="studentMsg.className == null">暂无</span></span
            >
          </div>
          <div style="padding: 10px 10px">
            正确填涂：<span style="background-color: #67c23a">[选项]</span>
          </div>
        </div>
        <div class="ansekahead-answer">
          <div
            class="studentmsg"
            v-for="(item, i) in paper.structureList"
            :key="i"
          >
            <span
              style="display: block; padding: 10px; background-color: #dcdfe6"
              >part{{ i + 1 }}--{{ item.name }}</span
            >
            <!-- 单项选择题 -->
            <div
              class="ansekahead-chose"
              v-if="item.beanName == 'singleChoiceServiceImpl'"
            >
              <div class="quest" v-for="(item1, i1) in item.bankList" :key="i1">
                <span
                  style="
                    display: block;
                    text-align: center;
                    line-height: 40px;
                    height: 40px;
                    font-weight: 600;
                    margin-right: 20px;
                    margin-left: 5px;
                  "
                  >{{ i1 + 1 }}.</span
                >
                <span
                  v-for="(item2, i3) in item1.options"
                  :key="i3"
                  :class="
                    item1.examAnswer.optiones == String.fromCharCode(i3 + 65)
                      ? 'quest-item-right'
                      : 'quest-item'
                  "
                  >{{ String.fromCharCode(i3 + 65) }}</span
                >
              </div>
            </div>
            <!-- 多项选择题 -->
            <div
              class="ansekahead-chose"
              v-if="item.beanName == 'multipleChoiceServiceImpl'"
            >
              <div class="quest" v-for="(item1, i1) in item.bankList" :key="i1">
                <span
                  style="
                    display: block;
                    text-align: center;
                    line-height: 40px;
                    height: 40px;
                    font-weight: 600;
                    margin-right: 20px;
                    margin-left: 5px;
                  "
                  >{{ i1 + 1 }}.</span
                >
                <span
                  v-for="(itemd, kk) in item1.options"
                  :key="kk"
                  :class="itemd.flag ? 'quest-item-right' : 'quest-item'"
                  >{{ String.fromCharCode(kk + 65) }}</span
                >
              </div>
            </div>
            <!-- 填空题 -->
            <div
              class="ansekahead-chose"
              v-if="item.beanName == 'completionServiceImpl'"
            >
              <div
                class="bankquest"
                v-for="(item1, i1) in item.bankList"
                :key="i1"
              >
                <span
                  style="
                    display: block;
                    text-align: center;
                    line-height: 40px;
                    height: 40px;
                    font-weight: 600;
                    margin-right: 20px;
                    margin-left: 5px;
                    vertical-align: bottom;
                  "
                  >{{ i1 + 1 }}.
                  <span
                    v-for="(itemd, kk) in item1.examAnswer.value"
                    :key="kk"
                    style="margin-left: 10px"
                  >
                    （{{ kk + 1 }}）{{ itemd }}
                  </span>
                </span>
              </div>
            </div>
            <!-- 判断题 -->
            <div
              class="ansekahead-chose"
              v-if="item.beanName == 'judgeServiceImpl'"
            >
              <div class="quest" v-for="(item1, i1) in item.bankList" :key="i1">
                <span
                  style="
                    display: block;
                    text-align: center;
                    line-height: 40px;
                    height: 40px;
                    font-weight: 600;
                    margin-right: 20px;
                    margin-left: 5px;
                    vertical-align: bottom;
                  "
                  >{{ i1 + 1 }}.

                  <el-radio-group
                    class="oneselect-body"
                    style="margin-top: -3px"
                    v-model="item1.examAnswer.optiones"
                    disabled
                  >
                    <el-radio label="true">正确</el-radio>
                    <el-radio label="false">错误</el-radio>
                  </el-radio-group></span
                >
              </div>
            </div>
            <!-- 简答题 -->
            <div
              class="ansekahead-chose"
              v-if="item.beanName == 'shortAnswerServiceImpl'"
            >
              <div
                class="quest"
                style="width: 100%"
                v-for="(item1, i1) in item.bankList"
                :key="i1"
              >
                <span
                  style="
                    display: block;
                    text-align: center;
                    padding: 10px 0;
                    font-weight: 600;
                    margin-right: 20px;
                    margin-left: 5px;
                  "
                  >{{ i1 + 1 }}.{{ item1.examAnswer.value }}</span
                >
              </div>
            </div>
            <!-- 大题 -->
            <div
              class="bigansekahead-chose"
              v-if="item.beanName == 'bigQuestionServiceImpl'"
            >
              <!-- 两层嵌套，然后用框包裹整个题目 -->

              <span
                style="text-align: center; font-weight: 600; margin-left: 5px"
                >{{ 1 }}.</span
              >
              <div
                class="ansekahead-chose"
                v-for="(obj, k) in item.bankList[0].bankList"
                :key="k"
              >
                <div
                  v-if="obj.beanName == 'singleChoiceServiceImpl'"
                  style="display: flex"
                >
                  <span
                    style="
                      display: block;
                      text-align: center;
                      line-height: 40px;
                      height: 40px;
                      font-weight: 600;
                      margin-right: 20px;
                      margin-left: 5px;
                    "
                    >（{{ k + 1 }}）</span
                  >
                  <span
                    v-for="(item2, i3) in obj.options"
                    :key="i3"
                    :class="
                      obj.examAnswer.optiones == String.fromCharCode(i3 + 65)
                        ? 'quest-item-right'
                        : 'quest-item'
                    "
                    >{{ String.fromCharCode(i3 + 65) }}</span
                  >
                </div>
                <div
                  v-if="obj.beanName == 'multipleChoiceServiceImpl'"
                  style="display: flex"
                >
                  <span
                    style="
                      display: block;
                      text-align: center;
                      line-height: 40px;
                      height: 40px;
                      font-weight: 600;
                      margin-right: 20px;
                      margin-left: 5px;
                    "
                    >（{{ k + 1 }}）</span
                  >
                  <!-- 这里报错要重写 -->
                  <span
                    v-for="(itemd, kk) in obj.options"
                    :key="kk"
                    :class="
                      obj.examAnswer.optiones == null ||
                      obj.examAnswer.optiones.indexOf(
                        String.fromCharCode(kk + 65)
                      ) == -1
                        ? 'quest-item'
                        : 'quest-item-right'
                    "
                    >{{ String.fromCharCode(kk + 65) }}</span
                  >
                </div>
                <div v-if="obj.beanName == 'completionServiceImpl'">
                  <span
                    style="
                      display: block;
                      text-align: center;
                      line-height: 40px;
                      height: 40px;
                      font-weight: 600;
                      margin-right: 20px;
                      margin-left: 5px;
                      vertical-align: bottom;
                    "
                    >（{{ k + 1 }}）

                    <span
                      v-for="(itemd, kk) in obj.examAnswer.value"
                      :key="kk"
                      style="
                        margin-left: 10px;
                        border-bottom: 2px solid #dcdfe6;
                      "
                    >
                      {{ itemd }}
                    </span>
                  </span>
                </div>

                <div v-if="obj.beanName == 'shortAnswerServiceImpl'">
                  <span
                    style="
                      display: block;
                      text-align: center;
                      padding: 10px 0;
                      font-weight: 600;
                      margin-right: 20px;
                      margin-left: 5px;
                    "
                    >（{{ k + 1 }}）{{ obj.examAnswer.value }}</span
                  >
                </div>
                <div v-if="obj.beanName == 'judgeServiceImpl'">
                  <span
                    style="
                      display: block;
                      text-align: center;
                      line-height: 40px;
                      height: 40px;
                      font-weight: 600;
                      margin-right: 20px;
                      margin-left: 5px;
                      vertical-align: bottom;
                    "
                    >（{{ k + 1 }}）

                    <el-radio-group
                      class="oneselect-body"
                      style="margin-top: -3px"
                      v-model="obj.examAnswer.optiones"
                      disabled
                    >
                      <el-radio label="true">正确</el-radio>
                      <el-radio label="false">错误</el-radio>
                    </el-radio-group></span
                  >
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </el-dialog>


  </div>
</template>

<script>
import fullscreen from 'vue-fullscreen'
import { getExam } from '@/api/exam/set'
// 引入试卷
import ShowPaper from './showPaper.vue'

import {
  liststu,
  listDetail,
  listQueryExam,
  exitExam,
  listexportStu,
  listexportPaper,
  batchReview,
  downLoadOneExam,
} from '@/api/exam/review'
import Vue from 'vue'
import { getExamPaper } from '@/api/paper/paper.js'
import { postAnswer } from '@/api/examination/examination.js'
import { downLoadZip } from '@/utils/zipdownload'

Vue.use(fullscreen)
export default {
  components: { ShowPaper },
  name: 'exam',
  //接收
  props: ['row'],
  data() {
    const item = {
      date: '2016-05-02',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1518 弄',
    }
    return {
      //查询学生信息
      sestuForm: {
        sessionId: '',
        userName: '',
        nickName: '',
        pageNum: 1,
        pageSize: 10,
      },
      // 总条数
      total: 0,
      templateinfo: [], //临时存储查询得到信息
      addressList: [], //场次
      sessionList: [], //场次下的学生
      studentMsg: [], //学生信息
      // 导出遮罩层
      exportLoading: false,
      exportLoadingp: false,
      showBatchReview: false,
      time: '24:00:00',
      answercardDialogVisible: false,
      answercardtitle: '',
      templatetiem: '',
      timeout: 0,
      timer: undefined, // 计时器，作用：组件销毁的时候需要把定时器清除
      shwostudent: false,
      shwopaper: false,
      showtip: true,
      fullscreen: true,
      tableData: Array(20).fill(item),
      breadcrumb: {
        first: '',
        second: '',
        // type:paper.structureList[0].type
        type: '',
      },
      headmue: {
        first: '',
        second: '',
      },
      //答题试卷组件的传值
      templatepape: [],
      //   题库
      paper: [],
    }
  },
  created() {
    // window.onresize = () => {
    //   if (!this.checkFull()) {
    //     // 退出全屏后要执行的动作
    //     this.$emit('ok', '子组件交卷')
    //     this.getList()
    //     this.fullscreen = false
    //     this.shwopaper = false
    //     this.answercardDialogVisible = false
    //   }
    // }
  },
  mounted() {
    // this.getExamPaperInfo();//获取考生信息和试卷信息
    // this.start(); //倒计时
    // this.gedetail();
    this.toggle(this.row);
  },
  methods: {
    // //导出成绩
    // handleExportstu(){
    //   console.log("导出的成绩")
    //   listexportStu(this.sestuForm).then((response) => {
    //     console.log("导出的成绩",response)
    //   });
    // },
    // 重置按钮
    refresh() {
      this.sestuForm.userName = ''
      this.sestuForm.nickName = ''

      this.getList()
    },
    //导出成绩
    handleExportstu() {
      this.$confirm('是否确认导出该场次的成绩数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          this.exportLoading = true
          return listexportStu(this.sestuForm)
        })
        .then((response) => {
          this.download(response.msg)
          this.exportLoading = false
        })
        .catch(() => {})
    },
    // 下载试卷
    handleExportpaper() {
      this.exportLoadingp = true
      let that = this
      this.$confirm('是否确认导出该场次的试卷数据?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then((res) => {
          downLoadZip(
            `/paper/paper/downloadPaper/${that.sestuForm.sessionId}`,
            `${that.row.name}`
          )
          setTimeout(() => {
            that.exportLoadingp = false
          }, 3000)
        })
        .catch(() => {
          that.exportLoadingp = false
        })
    },

    // 下载单个试题
    downExamRow(row) {
      this.$confirm(`是否确认导出${row.nickName}试卷数据?`, '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          downLoadZip(
            `/paper/paper/downloadPaperByStu/${row.id}`,
            `${row.userName}--${row.nickName}`,
            'pdf'
          )
        })
        .catch(() => {})
    },

    // 批量批阅
    batchReview() {
      this.$confirm('是否批量批阅?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          this.showBatchReview = true
          return batchReview(this.sestuForm)
        })
        .then((res) => {
          if (res == 'SUCCESS') {
            this.$message('后台正在批阅中')
          }
          setTimeout(() => {
            this.showBatchReview = false
          }, 3000)
        })
        .catch(() => {})
    },

    //保存退出
    exitanswer() {
      //        const info={
      //         examineeId:this.templateinfo.id,
      //          }
      this.$emit('parentEvent', '子组件交卷')
      // exitExam({
      //   examineeId: this.templateinfo.id,
      // }).then((response) => {
      //   this.getList()
      //   this.fullscreen = false
      //   this.shwopaper = false
      //   this.showtip = true
      //   this.answercardDialogVisible = false
      // })
    },
    //点击展开行后获取场次内的学生信息
    beforegetList(itemid) {
      for (let i = 0; i < this.addressList.length; i++) {
        if (this.addressList[i].id == itemid) {
          this.addressList[i].changecolor = true
        } else {
          this.addressList[i].changecolor = false
        }
      }
      this.$forceUpdate()
      this.sestuForm.sessionId = itemid
      this.getList()
    },
    /** 查询引入考生列表 */
    getList() {
      this.loading = true
      liststu(this.sestuForm).then((response) => {
        this.sessionList = response.rows
        this.total = response.total
      })
    },
    //查询考试信息，场次
    gedetail() {
      const id = this.row.id
      getExam(id).then((response) => {
        this.addressList = response.data.sessionList
        this.sestuForm.sessionId = this.addressList[0].id
        this.getList()
        for (let i = 0; i < this.addressList.length; i++) {
          if (i == 0) {
            this.addressList[i].changecolor = true
          } else {
            this.addressList[i].changecolor = false
          }
        }
      })
    },
    //   /**
    //    * 是否全屏并按键ESC键的方法
    checkFull() {
      //判断浏览器是否处于全屏状态 （需要考虑兼容问题）
      var isFull =
        document.mozFullScreen ||
        document.fullScreen ||
        //谷歌浏览器及Webkit内核浏览器
        document.webkitIsFullScreen ||
        document.webkitRequestFullScreen ||
        document.mozRequestFullScreen ||
        document.msFullscreenEnabled
      if (isFull === undefined) {
        isFull = false
      }
      return isFull
    },

    //是否全屏
    toggle(row) {
      console.log(row)
      this.templateinfo = row;
      console.log("templateinfo: ",this.templateinfo)
      const info = {
        examineeId: this.templateinfo.id,
        sessionId: this.templateinfo.sessionId,
        paperId: this.templateinfo.paperId,
      }

      listQueryExam(info).then((res) => {
        console.log("res:",res);
        this.templatepape = res;
        this.getExamPaperInfo();
        // this.fullscreen = !this.fullscreen
        this.shwopaper = true;
        this.showtip = false;
        this.shwostudent=true;
      })

      // this.templateinfo = row;
      // this.getExamPaperInfo();
      // // this.templatepape = row;
      // this.fullscreen = !this.fullscreen;
      // this.shwopaper = true;
    },
    //交卷
    submitanswer() {
      postAnswer({ examineeId: this.row.examineeId }).then((res) => {
        this.$emit('ok', '子组件交卷')
        this.fullscreen = false
        this.shwopaper = false
        this.answercardDialogVisible = false
        this.getList()
      })
      //交卷退出全屏
    },
    //答题卡
    answercard() {
      this.answercardDialogVisible = true
      this.getExamPaperInfo()
    },
    //点击摸一个菜单
    chosemue(index, indexPath) {
      // let arr =
      //   this.paper.structureList[index[0] - 1].bankList[index[2] - 1].id;
      let data = indexPath[1].split('-')
      let arr =
        this.paper.structureList[index[0] - 1].bankList[parseInt(data[1] - 1)]
          .id
      document.querySelector('#a' + arr).scrollIntoView(true)
      this.breadcrumb.first = indexPath[0]
      this.breadcrumb.type = this.paper.structureList[index[0] - 1].type
      this.breadcrumb.second = indexPath[1]
    },
    //打开导航栏
    handleOpen(key, keyPath) {},
    //关闭导航栏
    handleClose(key, keyPath) {},

    //倒计时处理
    countDown() {
      let tiem = Date.parse(this.row.sessionEndTime) - Date.parse(new Date()) // 获取时间差
      this.templatetiem = tiem / 1000 //时间戳转化为秒
      // 中间注释部分是提交答案的接口
      if (this.templatetiem <= 0) {
        this.submitanswer()
        //调用父组件关闭diaolog
      }
      // let hour = now.getHours(); // 时
      // let min = now.getMinutes(); // 分
      // let sec = now.getSeconds(); // 秒
      // let result = ''; // 返回结果
      // let h = 24 - hour; // 一天中剩下的时间(小时)
      // if (min > 0 || sec > 0) {
      //     h -= 1
      // }
      // let m = 60 - min; // 一天中剩下的时间(分钟)
      // if (sec > 0) {
      //     m -= 1
      // }
      // if (m == 60) {
      //     m = 0
      // }
      // let s = 60 - sec; // 一天中剩下的时间(秒)
      // if (s == 60) {
      //     s = 0
      // }
      let nowtime = this.templatetiem
      let h = parseInt(nowtime / 3600) // 时
      let m = parseInt(nowtime / 60 - h * 60) // 分
      let s = parseInt(nowtime - h * 3600 - m * 60) // 秒
      let result = '' // 返回结果
      h = h.toString()
      m = m.toString()
      s = s.toString()
      if (h.length == 1) {
        // 补0
        h = '0' + h
      }
      if (m.length == 1) {
        // 补0
        m = '0' + m
      }
      if (s.length == 1)
        // 补0
        s = '0' + s
      result = h + ':' + m + ':' + s
      return result
    },
    start() {
      let that = this
      this.timer = setInterval(function () {
        that.time = that.countDown()
      }, 1000)
    },
    // 查询答题卡和菜单
    getExamPaperInfo() {
      console.log(this.templateinfo)
      const info = {
        examineeId: this.templateinfo.id,
        sessionId: this.templateinfo.sessionId,
        paperId: this.templateinfo.paperId,
      }
      listQueryExam(info).then((res) => {
        this.studentMsg = res.examinee
        for (let i = 0; i < res.paper.structureList.length; i++) {
          res.paper.structureList[i].index = i + 1
          //处理大题内部的填空题
          if (res.paper.structureList[i].beanName == 'bigQuestionServiceImpl') {
            for (
              let j = 0;
              j < res.paper.structureList[i].bankList[0].bankList.length;
              j++
            ) {
              if (
                res.paper.structureList[i].bankList[0].bankList[j].beanName ==
                'completionServiceImpl'
              ) {
                if (
                  res.paper.structureList[i].bankList[0].bankList[j].examAnswer
                    .value != null
                ) {
                  res.paper.structureList[i].bankList[0].bankList[
                    j
                  ].examAnswer.value =
                    res.paper.structureList[i].bankList[0].bankList[
                      j
                    ].examAnswer.value.split('^^')
                }
              }
            }
          } else if (
            res.paper.structureList[i].beanName == 'multipleChoiceServiceImpl'
          ) {
            res.paper.structureList[i] = this.regMuch(
              res.paper.structureList[i]
            )
          } else if (
            res.paper.structureList[i].beanName == 'completionServiceImpl'
          ) {
            res.paper.structureList[i] = this.regbank(
              res.paper.structureList[i]
            )
          }
          for (let k = 0; k < res.paper.structureList[i].bankList.length; k++) {
            res.paper.structureList[i].bankList[k].index = k + 1
          }
        }
        this.paper = res.paper;
        console.log("paper:",this.paper);
        //  this.breadcrumb.type=this.paper.structureList[0].type
      })
    },
    //处理填空
    regbank(arr) {
      for (let i = 0; i < arr.bankList.length; i++) {
        if (arr.bankList[i].examAnswer.value != null) {
          arr.bankList[i].examAnswer.value =
            arr.bankList[i].examAnswer.value.split('^^')
        }
      }
      return arr
    },
    //   处理多选
    regMuch(arr) {
      for (let i = 0; i < arr.bankList.length; i++) {
        if (arr.bankList[i].examAnswer.value != null) {
          arr.bankList[i].examAnswer.value =
            arr.bankList[i].examAnswer.value.split('^^')
          // 循环选项
          for (let k = 0; k < arr.bankList[i].options.length; k++) {
            // 选项已选
            for (let j = 0; j < arr.bankList[i].examAnswer.value.length; j++) {
              if (
                arr.bankList[i].examAnswer.value[j] ==
                arr.bankList[i].options[k].context
              ) {
                arr.bankList[i].options[k].flag = true
                break
              } else {
                arr.bankList[i].options[k].flag = false
              }
            }
          }
        }
      }
      return arr
    },
  },
  destroyed() {
    clearInterval(this.timer) // 组件销毁时清除定时器
  },
}
</script>
<style lang="scss">
.container {
  height: 100%;
  width: 100%;
  background-color: #fff;
}
.el-header {
  background-color: #b3c0d1;
  color: #333;
  line-height: 60px;
}

.el-aside {
  color: #333;
}
.button {
  margin-top: 20px;
  font-size: 20px;
  width: 120px;
  height: 50px;
  border-radius: 30px;
}
.subbutton {
  width: 100%;
  height: 40px;
  margin-top: 20px;
  font-size: 18px;
}
.studentforn {
  width: 100%;
  height: 40px;
  background-color: #00cdcd;
  margin-bottom: 20px;
  font-size: 18px;
  color: #fff;
}
.box-card {
  margin-bottom: 20px;
}
.img {
  text-align: center;
}
.timeclick {
  border: 2px solid #e4e7ed;
  background-color: #fff;
  margin-bottom: 20px;
  text-align: center;
  font-size: 40px;
  font-weight: 600;
}
.spantime {
  display: block;
  margin: 10px 10px;
}
.el-header {
  background-color: #b3c0d1;
  color: #333;
  line-height: 60px;
}
.header {
  text-align: right;
  font-size: 18px;
  line-height: 60px;
}
.ansekahead {
  font-size: 24px;
  font-weight: 600;
  text-align: center;
}
.studentmsg {
  margin-top: 20px;
  font-size: 18px;
}
.studentmsg-ietm {
  padding: 10px 10px;
  display: flex;
  justify-content: space-between;
}
.quest {
  border: 1px solid #dcdfe6;
  display: flex;
  width: 25%;
}
.bankquest {
  border-bottom: 1px solid #dcdfe6;
  display: flex;
  width: 100%;
}
.search_from {
  display: flex;
  .el-button {
    margin-left: 15px;
  }
}
.quest-item {
  display: block;
  background-color: #c0c4cc;
  padding-bottom: 3px;
  margin: 5px;
  text-align: center;
  line-height: 30px;
  border-radius: 5px;
  width: 30px;
  height: 30px;
  font-weight: 600;
}
.quest-item-right {
  display: block;
  background-color: #67c23a;
  padding-bottom: 3px;
  margin: 5px;
  text-align: center;
  line-height: 30px;
  border-radius: 5px;
  width: 30px;
  height: 30px;
  font-weight: 600;
}
.ansekahead-chose {
  display: flex;
  flex-wrap: wrap;
  margin-top: 20px;
  font-size: 18px;
}
.bigansekahead-chose {
  display: flex;
  flex-wrap: wrap;
  margin-top: 20px;
  font-size: 18px;
  border: 2px solid #e4e7ed;
}
.sidePosi {
  width: 15%;
  height: 100vh;
  background-color: rgb(238, 241, 246);
  overflow-y: auto;
  position: fixed;
}
.chose {
  background-color: #e4e7ed;
}
.nav {
  display: flex;
}
.contentchange {
  border-radius: 28px;
  margin-right: 10px;
  right: 5px;
  text-align: center;
}
.content {
  margin-right: 10px;
  border-radius: 28px;
  background-color: #409eff;
  color: #f1f1f1;
}
.sessionIdspan {
  display: block;
  font-size: 18px;
  height: 35px;
  line-height: 35px;
  padding-left: 10px;
  padding-right: 10px;
}
</style>
